﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:models="using:WinKee.Models"
    xmlns:Converters="using:WinKee.Converters"
    x:Class="WinKee.Controls.DetailsEntrySection"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400" d:DataContext="{d:DesignInstance models:PasswordEntry}">

    <UserControl.Resources>
        <Converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
        <Converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter"/>
    </UserControl.Resources>

    <StackPanel Orientation="Vertical">
        <TextBlock Visibility="{Binding Url, Converter={StaticResource NullToVisibilityConverter}}" FontSize="26" Text="URL"/>
        <TextBlock  Visibility="{Binding Url, Converter={StaticResource NullToVisibilityConverter}}" Text="{Binding Url}" Style="{StaticResource BodyTextBlockStyle}" TextWrapping="Wrap" Foreground="{StaticResource PhoneAccentBrush}" FontSize="20"/>
        <Button Visibility="{Binding Url, Converter={StaticResource NullToVisibilityConverter}}" Content="Open in browser" x:Name="NavigateToUrlButton" Click="NavigateToUrlButton_OnClick"/>

        <TextBlock Visibility="{Binding HasExpiration, Converter={StaticResource BoolToVisibilityConverter}}" FontSize="26" Text="Expiration time:"/>
        <TextBlock Visibility="{Binding HasExpiration, Converter={StaticResource BoolToVisibilityConverter}}" Style="{StaticResource BodyTextBlockStyle}" Text="{Binding ExpirationTime}" Foreground="{StaticResource PhoneAccentBrush}"/>

        <TextBlock FontSize="26" Text="Last modification:"/>
        <TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding ModificationTime}" Foreground="{StaticResource PhoneAccentBrush}" />

        <Grid Margin="0,10" Visibility="{Binding Password, Converter={StaticResource NullToVisibilityConverter}}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition />
            </Grid.RowDefinitions>
            <TextBlock Grid.Column="0" Grid.Row="0" Style="{StaticResource BodyTextBlockStyle}" Text="Password quality:" />
            <TextBlock Grid.Column="1" Grid.Row="0" Style="{StaticResource BodyTextBlockStyle}" Text="{Binding PasswordStrength}" Foreground="{StaticResource PhoneAccentBrush}" />
            <TextBlock Grid.Column="0" Grid.Row="1" Style="{StaticResource BodyTextBlockStyle}" Text="Password entropy:" />
            <TextBlock Grid.Column="1" Grid.Row="1" Style="{StaticResource BodyTextBlockStyle}" Text="{Binding PasswordEntropy}" Foreground="{StaticResource PhoneAccentBrush}" />
            <ProgressBar Margin="0,5" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" Minimum="0" Maximum="1" Visibility="{Binding Password, Converter={StaticResource NullToVisibilityConverter}}" Value="{Binding PasswordEntropyPercent}" Height="15"/>
        </Grid>

        <TextBlock FontSize="26" Text="Path:"/>
        <TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding Path}" Foreground="{StaticResource PhoneAccentBrush}" TextWrapping="Wrap" />
    </StackPanel>
</UserControl>
